package montecarlo.control;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.Random;
import java.util.concurrent.ExecutionException;

/**
 * 
 * @author Lizeth
 */
public class ControlMC {
	private int cores;
	private int poolSize;
	private double blockingCoefficient;

	public ControlMC() {
		cores = Runtime.getRuntime().availableProcessors();
		blockingCoefficient = 0.1;
		poolSize = (int) (cores / (1 - blockingCoefficient));
	}

	/**
	 * To retrieve data from txt file
	 * 
	 * @param selectedItem
	 * @return Array of one set of data
	 * @throws IOException
	 */
	public String[] getData(int selectedItem) throws IOException {

		final BufferedReader reader = new BufferedReader(new FileReader(
				"dataSets.txt"));
		String stockInfo = null;
		String[] stockInfoData = null;
		for (int i = 0; i <= selectedItem; i++) {
			if ((stockInfo = reader.readLine()) != null) {
				stockInfoData = stockInfo.split(",");
			}
		}
		return stockInfoData;
	}

	public int getCores() {
		return cores;
	}

	public void setCores(int cores) {
		this.cores = cores;
	}

	public int getPoolSize() {
		return poolSize;
	}

	public void setPoolSize(int poolSize) {
		this.poolSize = poolSize;
	}

	public double getBlockingCoefficient() {
		return blockingCoefficient;
	}

	public void setBlockingCoefficient(double blockingCoefficient) {
		this.blockingCoefficient = blockingCoefficient;
	}

}
